#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

my $email = "yinche\@cisco.com";
my $url = "http://172.18.138.102/cgi-bin/wMOS-bk.cgi";
my $client_ip = $ENV{'REMOTE_ADDR'};
my @ap_info = qx(/usr/bin/perl getAPInfo.pl);
print header;
print start_html("wMOS");
my @fields = param;
if (@fields == 0) { 
	print <<EndHTML;
	<h2>wMOS Test</h2>
	<p>
	My e-mail address is $email, and this is a demo wMOS web page URL: <a href="$url">$url</a>.
	</p>

	<p> Local IP address: $client_ip </p>
	<p> Please Click the 'start MOS' button to start the test </p>
EndHTML
	print start_form(-method=>'POST', -action=>"/cgi-bin/wMOS-bk.cgi"), hidden('ap_ip',  $ap_info[0]), submit(-name=>'sub_form', -value=>'Start MOS'), end_form, hr;
} else {
	my $ap_ip = param('ap_ip'); 	
	print <<ENDHTML;

	<p> AP IP address: $ap_ip </p>
	<body onload="init()" style="height:100%; display:block">
      <div id="videoWindow"> 
	<object width="425" height="350">
	  <param name="movie" value="http://www.youtube.com/v/5_sfnQDr1-o" />
	  <embed src="http://www.youtube.com/v/5_sfnQDr1-o"
		 type="application/x-shockwave-flash" width="425" height="350" />
	</object>
      </div>
	<div id="windDown">
	The testing is underway.<br/>
	Please play and watch the video in the window, above.<br/>
	When the video ends, please enter the score for your experience in watching the video into the box below.<br/>
	Then, press the button to end the test.<br/>
	<table border="1">
	  <tr>
	    <td colspan="3">Scoring Chart</td>
	  </tr>
	  <tr>
	    <td>Score</td><td>Quality</td><td>Impairment</td>
	  </tr>
	  <tr>
	    <td>5</td><td>Excellent</td><td>Imperceptible</td>
	  </tr>
	  <tr>
	    <td>4</td><td>Good</td><td>Perceptible but not annoying</td>
	  </tr>
	  <tr>
	    <td>3</td><td>Fair</td><td>Slightly annoying</td>
	  </tr>
	  <tr>
	    <td>2</td><td>Poor</td><td>Annoying</td>
	  </tr>
	  <tr>
	    <td>1</td><td>Bad</td><td>Very annoying</td>
	  </tr>
	</table>
	Wi-Fi Quality Score: <input type="text" id="wMOS" style="background-color:#addfff" value="" size="4" onchange=""/>
	<input type="button" value="End Testing" onclick="endTesting()"/><br/>
      </div>



ENDHTML
}
print end_html;
